package com.zhku.meeting.controller;

import com.alibaba.druid.sql.ast.statement.SQLForeignKeyImpl;
import com.zhku.meeting.Annotation.loginCharacter;
import com.zhku.meeting.entities.Equipment;
import com.zhku.meeting.entities.Msg;
import com.zhku.meeting.service.EquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class EquipmentController {

    @Autowired
    private EquipmentService equipmentService;

    @loginCharacter
    @GetMapping("/equip")
    public Msg getEquip(@RequestParam Map<String,Object> para){
        return equipmentService.getEquip(para);
    }

    //分页查询所有设备信息
    @loginCharacter
    @GetMapping("/equips")
    public Msg getAllEquip(@RequestParam Map<String,Object> para){
        return equipmentService.getAll(para);
    }

    //更新设备信息，带什么改什么
    @loginCharacter
    @PutMapping("/equip")
    public Msg update(@RequestBody Map<String,Object> para){
//        Msg msg = equipmentService.duplicateCheck(para);
        return equipmentService.update(para);
    }

    //添加设备
    @loginCharacter
    @PostMapping("/equip")
    public Msg add(@RequestBody Map<String,Object> para){
//        Msg msg = equipmentService.duplicateCheck(para);
//        if(msg.getCode()==400){
//            return msg;
//        }
        return equipmentService.addEquip(para);
    }

    //删除设备
    @loginCharacter
    @DeleteMapping("/equip")
    public Msg delete(@RequestBody Map<String,Object> para){
        return equipmentService.deleteById(para);
    }

    //模糊条件查询
    @loginCharacter
    @GetMapping("/equipCondition")
    public Msg selectCondition(@RequestParam Map<String, Object> para){
        return equipmentService.selectCondition(para);
    }
}
